<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/class_address.php');
include('class/class_workdays.php');
include('class/class_acts.php');
include('class/abstract/class_paginator.php');
include('class/abstract/class_mainObjectInfo.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');
//начало блока безопасности
foreach($_GET as $key=>$val)
{
	$_GET[$key]=checkGetData::safetyCheck($val);
}
if(!($_GET['obj']=='firms' || $_GET['obj']=='malls' || $_GET['obj']=='malls'))
	checkGetData::error();
if($_GET['obj']=='nets')
{
	$table='nets_acts';
	$aCheck=new checkGetData('main');
	$aCheck->checkTableId($table, $_GET['id']);
}
else
{
	$aCheck=new checkGetData(substr($_GET['obj'], 0, 1).'a');
	$aCheck->checkTableId($_GET['city'], $_GET['id']);
}
session_start();
$table=$_GET['city'];
if($_GET['obj']=='nets')
{
	$aConnect=new connect('main');
	$table='nets_acts';
}
else
	$aConnect=new connect(substr($_GET['obj'], 0, 1).'a');
$row=mysql_fetch_array($aConnect->select_all($table, "WHERE id='".$_GET['id']."'"));
if($_GET['obj']=='nets')
{
	$aConnect=new connect('main');
	$table='nets';
}
else
	$aConnect=new connect(substr($_GET['obj'], 0, 1));
$r=mysql_fetch_array($aConnect->select_all($table, "WHERE id='".$row[$_GET['obj'].'_id']."'"));
if(!$_SESSION['login'])
{
	header('location: registr.php?city='.$_GET['city']);
	exit;
}
if(strtolower($_SESSION['login'])!=strtolower($r['user']))
	checkGetData::error();
//конец блока безопасности
class aFirmPage extends page
{
	var $row=array();
	var $cityRus;
	var $r;
	function __construct($row=array(), $r=array())
	{
		$this->row=$row;
		$this->r=$r;
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo $this->row['name'].' '.$this->cityRus->city_rus_im($_GET['city']);
	}
	function maincontent()
	{
		if($_GET['obj']=='nets')$objRus='Мои сети';
		elseif($_GET['obj']=='firms')$objRus='Мои фирмы';
		elseif($_GET['obj']=='malls')$objRus='Мои центры';
		echo ('
		<div class="route">
			<div class="routeEl">
				<a href="pcabinet.php?city='.$_GET['city'].'">Личный кабинет</a>
			</div>
			<div class="routeEl">
				<a href="my_'.$_GET['obj'].'.php?city='.$_GET['city'].'">'.$objRus.'</a>
			</div>
			<div class="routeEl">
				<a href="'.$_GET['obj'].'cabinet.php?city='.$_GET['city'].'&id='.$this->row['id'].'">'.$this->row['name'].'</a>
			</div>
			<div class="routeEl">
				События
			</div>
		</div>
		');
		$info=new aFirmInfo($this->row);
		echo '<center><h1>События</h1></center>';
		$row=$this->r;
		echo '
		<link rel="stylesheet" href="style/acts.css" />
		<div class="acts">
			<table border="0">
		';
       $act=new acts;
       echo $act->showAnAct($_GET['obj'], $row['id'], $row['name'], $row['stext'], $row['data'], $row[$_GET['obj'].'_id'], $row[$_GET['obj'].'_name'], $row[$_GET['obj'].'_short'],  $textLimit="", true);
       echo ('
       		</table>
       </div>
       ');
	}
}


class aFirmInfo extends mainObjectInfo
{
	var $row;
	function __construct($row=array())
	{
		$this->row=$row;
		parent::__construct();
	}
	function showPic()
	{
		$img='<img src="pictures/'.$_GET['obj'].'pics/'.$_GET['city'].'/'.$this->row['id'].'.jpg" title="'.$this->row['name'].'">';
		if($_GET['obj']=='nets')$img='<img src="pictures/'.$_GET['obj'].'pics/'.$this->row['id'].'.jpg" title="'.$this->row['name'].'">';
		echo $img;
	}
	function showAddress()
	{
		$address=new address();
		if($_GET['obj']=='firms')
			$address->showSeveralAddresses($this->row['address'], $this->row['link']);
		else
		{
			$addr=explode(',', $this->row['address']);
			$explAddress=$addr[0].'^'.$addr[1].'^'.$this->row['phone'].'^^'.$this->row['workdays'];
			$address->showAddress($explAddress,  $this->row['link']);
		}
	}
	function showshort()
	{
		echo $this->row['short'];
	}
	function showName()
	{
		echo $this->row['name'];
	}
}

$aPage=new aFirmPage($r, $row);

?>